#include<bits/stdc++.h>
using namespace std;
int main()
{
    //最优二叉搜索树
    int n;//树有n个节点
    while(cin>>n)
    {
        double*p=new double[n+1];//节点概率
        double*q=new double[n+1];//伪节点概率
        p[0]=0;
        for(int i=1;i<=n;i++){cin>>p[i];}
        for(int i=0;i<=n;i++){cin>>q[i];}
        double**e=new double*[n+2];//i到j的最优价值数组
        double**w=new double*[n+2];//i到j的概率数组
        int**root=new int*[n+1];//i到j的根节点数组
        for(int i=1;i<=n;i++)
        {
            root[i]=new int[n+1];
            for(int j=1;j<=n;j++)
            {
                root[i][j]=INT_MAX;
            }
        }
        for(int i=0;i<n+2;i++)
            {
                w[i]=new double[n+1];
                e[i]=new double[n+1];
                for(int j=0;j<n+1;j++){
                    w[i][j]=INT_MAX;
                    e[i][j]=INT_MAX;
                }
            }
        for(int i=1;i<=n+1;i++)//初始化
        {
            w[i][i-1]=q[i-1];
            e[i][i-1]=q[i-1];
        }
        int i,k,j,l;
        for(l=1;l<=n;l++)
        {
            for(i=1;i<=n+1-l;i++)
            {
                j=i+l-1;
                e[i][j]=INT_MAX;
                w[i][j]=w[i][j-1]+p[j]+q[j];
                for(k=i;k<=j;k++)
                {
                    double tmp=e[i][k-1]+e[k+1][j]+w[i][j];
                    if(tmp<e[i][j])
                    {
                        e[i][j]=tmp;
                        root[i][j]=k;
                    }
                }
            }
        }
        cout<<e[1][n]<<endl;
        cout<<root[1][n]<<endl;
    }
}